home *** CD-ROM | disk | FTP | other *** search
/ Java Certification Exam Guide / McGrawwHill-JavaCertificationExamGuide.iso / pc / Web Links and Code / ans / chap17 / exer1702 / MyButtonApplet.java
Encoding:
Java Source  |  1997-04-20  |  477 b   |  24 lines

  1. import java.awt.*;
  2. import java.applet.*;
  3.  
  4. public class MyButtonApplet extends Applet {
  5.    public void init() {
  6.       String s = getParameter("button");
  7.  
  8.       if (s == null)
  9.          s = new String("giraffe");
  10.  
  11.       add(new MyButton(s));
  12.    }
  13. }
  14.  
  15. class MyButton extends Button {
  16.    MyButton(String s) {
  17.       super(s);
  18.    }
  19.    public boolean action(Event e, Object what) {
  20.       System.out.println(getLabel());
  21.       return super.action(e, what);
  22.    }
  23. }
  24.